(function (__karma__, seajs) {
    'use strict';
    var tests = [],
        file;
    var alias = {
        'jquery': 'static_public/js/jquery.js',
        'angular': 'static_public/node_modules/angular/angular.js',
        'angular-mocks': 'test/angular_mocks_cmd.js',
        'datepicker': 'static_public/js/lib/wdatepicker.cmd.js',
        'dialog': '/static_public/js/artdialog.js',
        'util': 'static_public/js/util.js',
        'underscore': 'static_public/node_modules/underscore/underscore.cmd.js'
    };
    for (file in __karma__.files) {
        if (__karma__.files.hasOwnProperty(file)) {
            if (/spec\.js$/i.test(file)) {
                tests.push(file); //所有的测试用例代码文件以spec结尾
            }
            //else if(!/test_main\.js/.test(file)){
            //  var name = file.match(/\/base\/([^.]+)\.js/)[1];
            //  console.info('name:'+name);
            //  alias[name] = file;
            //}
        }
    }

    seajs.config({
        base: '/base',
        alias: alias,
        preload: ['jquery']
    });
    seajs.on('fetch', function (data) {
        var uri = data.uri;
        var pre = '/base';
        var aElement = document.createElement('a');
        aElement.href = uri;
        if (aElement.pathname.indexOf(pre) !== 0) {
            aElement.pathname = pre + aElement.pathname;
            data.requestUri = aElement.href;
        }
    });

    var __start = __karma__.start;
    __karma__.start = function () {
    };
    seajs.use(tests, function () {
        __start.call(); //要在seajs模块载入后调用,否则会加载不到任何测试用例
    });

})(window.__karma__, seajs);